package com.gitee.wsl.struct.command.model.parameters

import com.gitee.wsl.struct.command.context.Context
import com.gitee.wsl.struct.command.internal.UsageError

interface TransformContext {
    /** The current context object */
    val context: Context

    /** Throw an exception indicating that usage was incorrect. */
    fun fail(message: String): Nothing
}

/** Issue a message that can be shown to the user */
fun TransformContext.message(message: String) {
    context.command.issueMessage(message)
}

data class HelpTransformContext(override val context: Context) : TransformContext {
    override fun fail(message: String): Nothing {
        throw UsageError(message)
    }
}
